package org.example.springboot.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.example.springboot.common.page.PageResult;
import org.example.springboot.common.service.impl.BaseServiceImpl;
import org.example.springboot.component.SseEmitterServer;
import org.example.springboot.dao.FmcStatusDao;
import org.example.springboot.entity.*;
import org.example.springboot.query.FmcStatusQuery;
import org.example.springboot.service.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Fz
 * @since 1.0.0 2024-08-01
 */
@Service
@AllArgsConstructor
public class FmcStatusServiceImpl extends BaseServiceImpl<FmcStatusDao, FmcStatus> implements FmcStatusService {

    @Override
    public PageResult<FmcStatus> page(FmcStatusQuery query) {
        QueryWrapper<FmcStatus> fmcStatusQueryWrapper = new QueryWrapper<>();
        if(StringUtils.isNotBlank(query.getDid())){
            fmcStatusQueryWrapper.like("did", query.getDid());
        }
        IPage<FmcStatus> page = this.page(query, fmcStatusQueryWrapper.orderByDesc("id"));
        return new PageResult<>(page.getRecords(), page.getTotal());
    }

}